/*
 * Group:PrePool K9-357 
 * 8/2010
 */
package control;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import blo.AddWordBLO;

/**
 * Control class for S02_contribute.jsp Methods is called in method
 * processAction(ActionRequest request, ActionResponse response) of
 * OnlineDictPortlet class
 */
public class Contribute extends BaseControl {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Perform when click button Home in S02_Contribute.jsp
	 * 
	 * @param request
	 * @param response
	 * @return null
	 * @throws PortletException
	 * @throws IOException
	 */
	public form.BaseForm procHome(ActionRequest request, ActionResponse response)
			throws PortletException, IOException {
		return null;
	}

	/**
	 * Perform when click button Submit in S02_Contribute.jsp
	 * 
	 * @param request
	 * @param response
	 * @return A Contribute's instance contains submitted informations
	 * @throws PortletException
	 * @throws IOException
	 */
	public form.Contribute procSubmit(ActionRequest request,
			ActionResponse response) throws PortletException, IOException {
		form.Contribute result = new form.Contribute();
		String txtWord = request.getParameter("txtWord");
		String txtmeaning = request.getParameter("txtTranslation");
		int dictID = Integer.valueOf(request.getParameter("dictID"));
		boolean success = new AddWordBLO().addSugestWord(txtWord, txtmeaning,
				dictID);

		if (success) {
			result.setSuccess(1);
		} else {
			result.setSuccess(0);
		}
		return result;
	}

	/**
	 * Perform when click button Cancel in S02_Contribute.jsp
	 * 
	 * @param request
	 * @param response
	 * @return null
	 * @throws PortletException
	 * @throws IOException
	 */
	public form.BaseForm procCancel(ActionRequest request,
			ActionResponse response) throws PortletException, IOException {
		return null;
	}
}
